﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ppt = Microsoft.Office.Interop.PowerPoint;
using System.ComponentModel;


namespace ObjectModel.PowerPoint
{
    public class LinkedObjectsBySlide : Dictionary<int, LinkedObjectCollection>, INotifyPropertyChanged
    {
        readonly SlideKeyDictionaryController<LinkedObjectCollection> mController;
        LinkedObjectCollection mActiveCollection;

        public event PropertyChangedEventHandler PropertyChanged;

        public LinkedObjectsBySlide(Ppt.Presentation pres)
        {
            mController = new SlideKeyDictionaryController<LinkedObjectCollection>(this, pres);
        }

        public new LinkedObjectCollection this[int slideID]
        {
            get
            {
                if (!base.ContainsKey(slideID))
                    base.Add(slideID, new LinkedObjectCollection());

                return base[slideID];
            }
        }

        public LinkedObjectCollection ActiveCollection
        {
            get { return mActiveCollection; }

            set
            {
                mActiveCollection = value;
                OnPropertyChanged("ActiveCollection");
            }
        }

        void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    //public class LinkedObjectsBySlide : NotificationBase
    //{
    //    readonly Dictionary<int, LinkedObjectCollection> mDict = new Dictionary<int, LinkedObjectCollection>();
    //    readonly LinkedObjectCollectionController mController;
    //    LinkedObjectCollection mActiveCollection;

    //    public LinkedObjectsBySlide(Ppt.Presentation pres)
    //    {
    //        mController = new LinkedObjectCollectionController(mDict, pres);
    //    }

    //    public LinkedObjectCollection this[int slideID]
    //    {
    //        get
    //        {
    //            if (!mDict.ContainsKey(slideID))
    //                mDict.Add(slideID, new LinkedObjectCollection());

    //            return mDict[slideID];
    //        }
    //    }

    //    public LinkedObjectCollection ActiveCollection
    //    {
    //        get { return mActiveCollection; }

    //        set
    //        {
    //            mActiveCollection = value;
    //            OnPropertyChanged("ActiveCollection");
    //        }
    //    }
    //}
}
